import { defineStore } from 'pinia'
import {getSession, setSession, removeSession} from '../utils/index.js'
export const useUsersStore = defineStore('users', {
  state: () => {
    return {
      userInfo: getSession('userInfo')
    };
  },
  actions: {
    // 缓存用户信息数据
    setUserInfo(obj) {
      this.userInfo = obj
      setSession("userInfo", obj)
    },
    // 清空用户信息
    clearUserInfo() {
      this.userInfo = {}
      removeSession('userInfo')
    }
  }
})